import request from '../utils/axios-config'

// 获取公告分页数据
export function getAnnouncementPage(params) {
  return request({
    url: '/admin/announcement/page',
    method: 'get',
    params
  })
}

// 获取公告详情
export function getAnnouncementDetail(announcementId) {
  return request({
    url: `/admin/announcement/detail/${announcementId}`,
    method: 'get'
  })
}

// 发布公告
export function publishAnnouncement(data) {
  return request({
    url: '/admin/announcement/publish',
    method: 'post',
    data
  })
}

// 更新公告
export function updateAnnouncement(data) {
  return request({
    url: '/admin/announcement/update',
    method: 'put',
    data
  })
}

// 删除公告
export function deleteAnnouncement(announcementId) {
  return request({
    url: `/admin/announcement/${announcementId}`,
    method: 'delete'
  })
}

// 更新公告状态
export function updateAnnouncementStatus(announcementId, status) {
  return request({
    url: `/admin/announcement/updateStatus/${announcementId}`,
    method: 'put',
    params: { status }
  })
}

// 置顶/取消置顶
export function updateAnnouncementTop(announcementId, isTop) {
  return request({
    url: `/admin/announcement/updateTop/${announcementId}`,
    method: 'put',
    params: { isTop }
  })
}

